import { BaseEntity } from '../../base/entity/base';
import { Column, Entity, Index } from 'typeorm';

/**
 * 用户信息
 */
@Entity('user_info')
export class UserInfoEntity extends BaseEntity {
  @Index({ unique: true })
  @Column({ comment: '登录唯一ID', nullable: true })
  unionid: string;

  @Column({ comment: '头像', nullable: true })
  avatarUrl: string;

  @Column({ comment: '昵称', nullable: true })
  nickName: string;

  @Index({ unique: true })
  @Column({ comment: '手机号' })
  phone: string;

  @Column({ comment: '状态', dict: ['禁用', '正常', '已注销'], default: 1 })
  status: number;

  @Column({ comment: '密码', nullable: true })
  password: string;

  @Column({ comment: '介绍', type: 'text', nullable: true })
  description: string;

  @Column({
    comment: '账户余额',
    type: 'decimal',
    precision: 10,
    scale: 2,
    default: 0,
  })
  balance: number;

  @Column({ comment: '角色', default: 0 }) // 0: 普通用户, 1: 代理, 2: 商户, 3: 平台
  role: number;

  @Column({ comment: '代理级别', nullable: true }) // 1: 一级代理, 2: 二级代理, 3: 三级代理
  agentLevel: number;

  @Column({
    comment: '分润比例',
    type: 'decimal',
    precision: 5,
    scale: 2,
    nullable: true,
  })
  profitRatio: number;

  // 商户号
  @Column({ comment: '商户号', nullable: true })
  merchantNo: string;

  // 终端号
  @Column({ comment: '终端号', nullable: true })
  terminalNo: string;
}
